package cn.edu.scau.cmi.liyetian.adapter;

import java.net.URL;
import java.util.ResourceBundle;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class AdapterController implements Initializable{
	Target classAdapter = new AdapterOfClass();
	Target objectAdapter = new AdapterOfObject();
	
	@FXML
	private TextField textField1;
	
	@FXML
	private TextField textField2;
	
	@FXML
	private TextArea textArea1;
	
	@FXML
	private TextArea textArea2;
	
	@FXML
	private Button button1;

	@Override
	public void initialize(URL location, ResourceBundle resources) {
		// TODO Auto-generated method stub
		
	}
	
	public void addStudent(ActionEvent event) {
		int number = Integer.parseInt(textField1.getText());
		String name = textField2.getText();
		System.out.println("添加学生["+number+","+name+"]成功");
		
		classAdapter.addUser(number, name);
		String str = classAdapter.sortStudent();
		textArea1.setText(str);
		
		objectAdapter.addUser(number, name);
		String str2 = objectAdapter.sortStudent();
		textArea2.setText(str);
	}
	
	
}
